﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using QuanLyVanBanBUS;

public partial class QLVB_User_DuyetSoanThaoMauBieu : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Page.IsPostBack == false)
        {
            layDanhSachMauBieuChuaDuyetTheoMaPhong();
        }
    }

    protected void layDanhSachMauBieuChuaDuyetTheoMaPhong()
    {
        PhongBUS pBUS = new PhongBUS();
        string maNguoiDung = (String)Session["MaNguoiDung"];
        string maPhong = pBUS.layMaPhongTheoMaNguoiDung(maNguoiDung);

        MauBieuBUS mbBUS = new MauBieuBUS();
        gvDuyetSoanThaoMauBieu.DataSource = mbBUS.layDanhSachMauBieuChuaDuyetTheoMaPhong(maPhong);
        gvDuyetSoanThaoMauBieu.DataBind();
    }
    protected void btnDuyet_Click(object sender, EventArgs e)
    {
        for (int i = 0; i < gvDuyetSoanThaoMauBieu.Rows.Count; i++)
        {
            CheckBox chkMaMauBieu = (CheckBox)(gvDuyetSoanThaoMauBieu.Rows[i].Cells[0].FindControl("chkMaMauBieu"));

            if (chkMaMauBieu.Checked)
            {
                MauBieu mbDTO = new MauBieu();
                mbDTO.MaNguoiKiemSoat = (String)Session["MaNguoiDung"];
                mbDTO.MaMauBieu = Convert.ToInt32(gvDuyetSoanThaoMauBieu.DataKeys[i].Value.ToString());
                
                MauBieuBUS mbBUS = new MauBieuBUS();
                mbBUS.duyetSoanThaoMauBieu(mbDTO);
            }
        }

        layDanhSachMauBieuChuaDuyetTheoMaPhong();
    }
    protected void btnDong_Click(object sender, EventArgs e)
    {

    }
    protected void chkChonTatCa_CheckedChanged(object sender, EventArgs e)
    {
        MyCheckBox myCheckBox = new MyCheckBox();

        if (chkChonTatCa.Checked)
        {
            myCheckBox.chonTatCa(gvDuyetSoanThaoMauBieu, "chkMaMauBieu", chkChonTatCa);
        }
        else
        {
            myCheckBox.huyTatCa(gvDuyetSoanThaoMauBieu, "chkMaMauBieu", chkChonTatCa);
        }
    }
    protected void gvDuyetSoanThaoMauBieu_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        gvDuyetSoanThaoMauBieu.PageIndex = e.NewPageIndex;

        layDanhSachMauBieuChuaDuyetTheoMaPhong();
    }
}